{/* LAYOUT模板 */}
	<layout name="layout"/>
{/* LAYOUT模板 */}

{/* import Js,Css */}
	<js href="__PUBLIC__/js/admin/listTable.js"/>
	<js href="__PUBLIC__/js/admin/js.util.js"/>
	<css href="__PUBLIC__/css/admin/common.css"/>
	<js href="__PUBLIC__/js/admin/js.selectzone.js"/>
	
	<css href="__PUBLIC__/css/jquery-ui.css" />
	<js href="__PUBLIC__/js/core/jquery-ui.1.10.4.js" />
	<js href="__PUBLIC__/js/core/plugins.js"/>
{/* import js,css */}

<!-- [position] -->
	<include file="Template:position"/>
<!-- [position] -->
<style>
#tab{margin-left:2px; margin-bottom:-2px;}#tab ul li{list-style:none;}#tab li{border:1px solid #b5e2f3;border-bottom:0px;float:left;width:100px;height:25px;margin:0 -1px;background:#F1FEF3;padding:9px 0 0 0;text-align:center;color:#33a3dc;cursor:pointer;}#tab ul{width:800px;height:36px;border-bottom:1px solid #b5e2f3;/*border-bottom:1px solid #b5e2f3;*/}#tab #selected{background:#FFF!important;border-bottom:2px solid #FFF!important;}ul{margin:-1px;}#cate1,#cate2, #cate3, #cate4, #cate5{clear:both;height:300px;background:#FFFFFF;width:800px;height:100px;padding:25px;height:auto;border:1px solid #b5e2f3;}
</style>


<ul style="padding:0; margin: 0; list-style-type:none; color: #CC0000;">
	<li style="border: 1px solid #CC0000; background: #FFFFCC; padding: 10px; margin-bottom: 5px;" >{$warning}</li>
</ul>

<div id="tab" >
	<ul>
		<li tar="cate1" id="selected">通用信息</li>
		<li tar="cate2">专属商品</li>
		<li tar="cate3">专题介绍</li>
		<li tar="cate4">高级选项</li>
	</ul>
</div>
<div>
	<div id="cate1" style="display:block;">
		<include file="Topics:general_1"/>
	</div>
	<div id="cate2" style="display:none;">
		<include file="Topics:goods_2"/>
	</div>
	<div id="cate3" style="display:none;">
		<include file="Topics:desc_3"/>
	</div>
	<div id="cate4" style="display:none;">
		<include file="Topics:advanced_4"/>
	</div>
</div>
<div class="tab-div">



	<div id="tabbar-div">
		<p>
			<span class="tab-front" id="general-tab">{$lang.tab_general}</span>
			<span class="tab-back" id="goods-tab">{$lang.tab_goods}</span> 
			<span class="tab-back" id="desc-tab">{$lang.tab_desc}</span>
			<span class="tab-back" id="advanced-tab">{$lang.tab_advanced}</span>
		</p>
	</div>
	<div id="tabbody-div">
		<form action="topic.php" method="post" name="theForm" enctype="multipart/form-data">
			<!--[通用信息]-->
			
			
			
			

			
			<div class="button-div">
				<input  name="topic_data" type="hidden" id="topic_data" value='' />
				<input  name="act" type="hidden" id="act" value='{$act}' />
				<input  name="topic_id" type="hidden" id="topic_id" value='{$topic.topic_id}' />
				<input type="submit"  name="Submit" value="确定" onclick="return checkForm()"/>
				<input type="reset"   name="Reset" value="重置" />
			</div>
		</form>
	</div>
</div>



<script type="Text/Javascript" language="JavaScript">
/*
var data = '{$topic.data}';
var defaultClass = "{$lang.default_class}";
var myTopic = Object();
var status_code = "{$topic.topic_type}"; // 初始页面参数

onload = function()
{
  
  // 开始检查订单
  startCheckOrder();
  var classList = document.getElementById("topic_class_list");

  // 初始化表单项
  initialize_form(status_code);

  if (data == "")
  {
    
    classList.innerHTML = "";
    myTopic['default'] = new Array();
    var newOpt    = document.createElement("OPTION");
    newOpt.value  = -1;
    newOpt.text   = defaultClass;
    classList.options.add(newOpt);
    return;
  }
  var temp    = data.parsejsON();

  var counter = 0;
  for (var k in temp)
  {
    if(typeof(myTopic[k]) != "function")
    {
      myTopic[k] = temp[k];
      var newOpt    = document.createElement("OPTION");
      newOpt.value  = k == "default" ? -1 : counter;
      newOpt.text   = k == "default" ? defaultClass : k;
      classList.options.add(newOpt);
      counter++;
    }
  }
  showTargetList();
}
*/

/**
 * 初始化表单项目

function initialize_form(status_code)
{
  var nt = navigator_type();
  var display_yes = (nt == 'IE') ? 'block' : 'table-row-group';
  status_code = parseInt(status_code);
  status_code = status_code ? status_code : 0;
  document.getElementById('topic_type').options[status_code].selected = true;

  switch (status_code)
  {
    case 0 :
      document.getElementById('content_01').style.display = display_yes;
      document.getElementById('content_23').style.display = 'none';
			document.getElementById('title_upload').innerHTML = '{$width_height}';
			document.getElementById('edit_img').style.display = display_yes;
    break;
		
    case 1 :
      document.getElementById('content_01').style.display = display_yes;
      document.getElementById('content_23').style.display = 'none';
			document.getElementById('title_upload').innerHTML = '{$lang.tips_upload_notice}';
			document.getElementById('edit_img').style.display = display_yes;
    break;
		
    case 2 :
      document.getElementById('content_01').style.display = 'none';
      document.getElementById('content_23').style.display = display_yes;
			document.getElementById('edit_img').style.display = 'none';
    break;
  }

	document.getElementById('edit_img').style.display = 'none';
	document.getElementById('edit_title_img').style.display = 'none';
  return true;
}
 */


/**
 * 类型表单项切换
 
function showMedia(code)
{
  var obj = document.getElementById('topic_type');

  initialize_form(code);
}

function checkForm()
{
  var validator = new Validator('theForm');
  validator.required('topic_name', topic_name_empty);
  validator.required('start_time', start_time_empty);
  validator.required('end_time', end_time_empty);
  validator.islt('start_time', 'end_time', start_lt_end);

  document.getElementById("topic_data").value = myTopic.tojsONString();

  return validator.passed();
}

function chanageSize(num, id)
{
  var obj = document.getElementById(id);
  if (obj.tagName == "TEXTAREA")
  {
    var tmp = parseInt(obj.rows);
    tmp += num;
    if (tmp <= 0) return;
    obj.rows = tmp;
  }
}

function searchGoods(catId, brandId, keyword)
{
  var elements = document.forms['theForm'].elements;
  var filters = new Object;
  filters.cat_id = elements[catId].value;
  filters.brand_id = elements[brandId].value;
  filters.keyword = Utils.trim(elements[keyword].value);
  Ajax.call("topic.php?act=get_goods_list", filters, function(result)
  {
    clearOptions("source_select");
    var obj = document.getElementById("source_select");
    for (var i=0; i < result.content.length; i++)
    {
      var opt   = document.createElement("OPTION");
      opt.value = result.content[i].value;
      opt.text  = result.content[i].text;
      opt.id    = result.content[i].data;
      obj.options.add(opt);
    }
  }, "GET", "jsON");
}

function clearOptions(id)
{
  var obj = document.getElementById(id);
  while(obj.options.length>0)
  {
    obj.remove(0);
  }
}

function addAllItem(sender)
{
  if(sender.options.length == 0) return false;
  for (var i = 0; i < sender.options.length; i++)
  {
    var opt = sender.options[i];
    addItem(null, opt.value, opt.text);
  }
}

function addItem(sender, value, text)
{
  var target_select = document.getElementById("target_select");
  var sortList = document.getElementById("topic_class_list");
  var newOpt   = document.createElement("OPTION");
  if (sender != null)
  {
    if(sender.options.length == 0) return false;
    var option = sender.options[sender.selectedIndex];
    newOpt.value = option.value;
    newOpt.text  = option.text;
  }
  else
  {
    newOpt.value = value;
    newOpt.text  = text;
  }
  if (targetItemExist(newOpt)) return false;
  if (target_select.length>=50)
  {
    alert(item_upper_limit);
  }
  target_select.options.add(newOpt);
  var key = sortList.options[sortList.selectedIndex].value == "-1" ? "default" : sortList.options[sortList.selectedIndex].text;
  
  if(!myTopic[key])
  {
    myTopic[key] = new Array();
  }
  myTopic[key].push(newOpt.text + "|" + newOpt.value);
}

// 商品是否存在
function targetItemExist(opt){
	var options = document.getElementById("target_select").options;
	for ( var i = 0; i < options.length; i++){
		if(options[i].text == opt.text && options[i].value == opt.value) {
			return true;
		}
	}
	return false;
}

function addClass(){
	var obj = document.getElementById("topic_class_list");
	var newClassName = document.getElementById("new_cat_name");
	var regExp = /^[a-zA-Z0-9]+$/;
	if (newClassName.value == ""){
		alert(sort_name_empty);
		return;
	}
	for(var i=0;i < obj.options.length; i++){
		if(obj.options[i].text == newClassName.value){
			alert(sort_name_exist);
			newClassName.focus(); 
			return;
		}
	}
	var className = document.getElementById("new_cat_name").value;
	document.getElementById("new_cat_name").value = "";
	var newOpt    = document.createElement("OPTION");
	newOpt.value  = obj.options.length;
	newOpt.text   = className;
	obj.options.add(newOpt);
	newOpt.selected = true;
	if ( obj.options[0].value == "-1"){
		if (myTopic["default"].length > 0)
			alert(move_item_confirm.replace("className",className));
		myTopic[className] = myTopic["default"];
		delete myTopic["default"];
		obj.remove(0);
	}
	else{
		myTopic[className] = new Array();
		clearOptions("target_select");
	}
}

function deleteClass(){
	var classList = document.getElementById("topic_class_list");
	if (classList.value != "-1"){
		delete myTopic[classList.options[classList.selectedIndex].text];
		classList.remove(classList.selectedIndex);
		clearOptions("target_select");
	}
	if (classList.options.length < 1){
		var newOpt    = document.createElement("OPTION");
		newOpt.value  = "-1";
		newOpt.text   = defaultClass;
		classList.options.add(newOpt);
		myTopic["default"] = new Array();
	}
}

function showTargetList(){
	clearOptions("target_select");
	var obj = document.getElementById("topic_class_list");
	var index = obj.options[obj.selectedIndex].text;
	if (index == defaultClass){
		index = "default";
	}
	var options = myTopic[index];

	for ( var i = 0; i < options.length; i++){
		var newOpt    = document.createElement("OPTION");
		var arr = options[i].split('|');
		newOpt.value  = arr[1];
		newOpt.text   = arr[0];
		document.getElementById("target_select").options.add(newOpt);
	}
}

function removeItem(sender,isAll){
	var classList = document.getElementById("topic_class_list");
	var key = 'default';
	if (classList.value != "-1"){
		key = classList.options[classList.selectedIndex].text;
	}
	var arr = myTopic[key];
	if (!isAll){
		var goodsName = sender.options[sender.selectedIndex].text;
		for (var j = 0; j < arr.length; j++){
			if (arr[j].indexOf(goodsName) >= 0){
				myTopic[key].splice(j,1);
			}
		}

		for (var i = 0; i < sender.options.length;){
			if (sender.options[i].selected) {
				sender.remove(i);
				myTopic[key].splice(i, 0);
			}
			else{
				i++;
			}
		}
	}
	else{
		myTopic[key] = new Array();
		sender.innerHTML = "";
	}
}
*/

	/**
	* 判断当前浏览器类型
	
	function navigator_type(){
		var type_name = '';
		if (navigator.userAgent.indexOf('MSIE') != -1){
			type_name = 'IE'; // IE
		}
		else if(navigator.userAgent.indexOf('Firefox') != -1){
			type_name = 'FF'; // FF
		}
		else if(navigator.userAgent.indexOf('Opera') != -1){
			type_name = 'Opera'; // Opera
		}
		else if(navigator.userAgent.indexOf('Safari') != -1){
			type_name = 'Safari'; // Safari
		}
		else if(navigator.userAgent.indexOf('Chrome') != -1){
			type_name = 'Chrome'; // Chrome
		}
		return type_name;
	}
	*/



</script>


<script>
	/**
	* 考虑到tab和pane有可能被动态的添加和删除，
	* 所以每次都废点时间去查找先前被激活的tab
	*/
	var tab = function(tabId,activeId){
	$("#"+tabId).delegate("li:not(#"+activeId+")","click",function(){
	$("#"+$("#"+activeId).attr("tar")).css("display","none");
	$("#"+activeId).removeAttr("id");
	 
	$(this).attr("id",activeId);
	$("#"+$(this).attr("tar")).css("display","block");
	});
	};
tab("tab","selected");
</script>




